package cn.wolfcode.config;

import cn.wolfcode.web.interceptor.CheckLoginInterceptor;
import cn.wolfcode.web.interceptor.CheckPermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private CheckLoginInterceptor checkLoginInterceptor;
    @Autowired
    private CheckPermissionInterceptor checkPermissionInterceptor;

    public static final String[] EXCLUDE_PATH={
            "/empLogin",
            "/messageBoard/list",
            "/systemDictionaryItem/selectForTypeId",
            "/messageReply/list",
            "/systemDictionaryItem/selectForTypeSn",
            "/appointment/save",
            "/index",
            "/login.html",
            "/css/**",
            "/js/**",
            "/img/**"
    } ;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(checkLoginInterceptor).addPathPatterns("/**")
                 .excludePathPatterns(EXCLUDE_PATH);
        registry.addInterceptor(checkPermissionInterceptor).addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);
    }
}
